﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace CoworkspaceAdmin.Models
{
    public partial class postgresContext : DbContext
    {
        public postgresContext()
        {
        }

        public postgresContext(DbContextOptions<postgresContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Company> Company { get; set; }
        public virtual DbSet<Project> Project { get; set; }
        public virtual DbSet<User> User { get; set; }

//         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//         {
//             if (!optionsBuilder.IsConfigured)
//             {
// #warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                // optionsBuilder.UseNpgsql("Server=47.92.28.96;Database=postgres;User ID=postgres;Password=postgreslike");
//                 var envstr = Environment.GetEnvironmentVariable("ygadmin_env");
//                 if (envstr == "prod") {
//                     optionsBuilder.UseNpgsql("Server=localhost;Database=postgres;User ID=postgres;Password=postgreslike");
//                 }else{
//                     optionsBuilder.UseNpgsql("Server=47.92.28.96;Database=postgres;User ID=postgres;Password=postgreslike");
//                 }
//             }
//         }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("ProductVersion", "2.2.0-rtm-35687");

            modelBuilder.Entity<Company>(entity =>
            {
                entity.HasKey(e => e.Name)
                    .HasName("company_pkey");

                entity.ToTable("company", "ygadmin");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .ValueGeneratedNever();

                entity.Property(e => e.Address).HasColumnName("address");

                entity.Property(e => e.Bp).HasColumnName("bp");

                entity.Property(e => e.ContactEmail)
                    .IsRequired()
                    .HasColumnName("contact_email");

                entity.Property(e => e.ContactName)
                    .IsRequired()
                    .HasColumnName("contact_name");

                entity.Property(e => e.ContactPhone)
                    .IsRequired()
                    .HasColumnName("contact_phone");

                entity.Property(e => e.Domain)
                    .IsRequired()
                    .HasColumnName("domain");

                entity.Property(e => e.EmpNum).HasColumnName("emp_num");

                entity.Property(e => e.EnterTime).HasColumnName("enter_time");

                entity.Property(e => e.LpName).HasColumnName("lp_name");

                entity.Property(e => e.LpPhone).HasColumnName("lp_phone");

                entity.Property(e => e.Projects)
                    .IsRequired()
                    .HasColumnName("projects");

                entity.Property(e => e.RegLicense).HasColumnName("reg_license");

                entity.Property(e => e.Regcapital).HasColumnName("regcapital");

                entity.Property(e => e.Registed).HasColumnName("registed");

                entity.Property(e => e.RequestDuration).HasColumnName("request_duration");

                entity.Property(e => e.Running).HasColumnName("running");

                entity.Property(e => e.Seats).HasColumnName("seats");

                entity.Property(e => e.Taxnum).HasColumnName("taxnum");

                entity.Property(e => e.Type)
                    .IsRequired()
                    .HasColumnName("type");

                entity.Property(e => e.Web).HasColumnName("web");
            });

            modelBuilder.Entity<Project>(entity =>
            {
                entity.ToTable("project", "ygadmin");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .ValueGeneratedNever();

                entity.Property(e => e.Advantages)
                    .IsRequired()
                    .HasColumnName("advantages");

                entity.Property(e => e.BcEduNum).HasColumnName("bc_edu_num");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasColumnName("name");

                entity.Property(e => e.Pattern).HasColumnName("pattern");

                entity.Property(e => e.PersonInvest).HasColumnName("person_invest");

                entity.Property(e => e.PrjInvest).HasColumnName("prj_invest");

                entity.Property(e => e.RdInvest).HasColumnName("rd_invest");

                entity.Property(e => e.RdNum).HasColumnName("rd_num");

                entity.Property(e => e.Resume).HasColumnName("resume");

                entity.Property(e => e.Sales).HasColumnName("sales");

                entity.Property(e => e.Stage)
                    .IsRequired()
                    .HasColumnName("stage");

                entity.Property(e => e.TechResource)
                    .IsRequired()
                    .HasColumnName("tech-resource");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.ToTable("user", "ygadmin");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .ValueGeneratedNever();

                entity.Property(e => e.Birthday)
                    .HasColumnName("birthday")
                    .HasColumnType("date");

                entity.Property(e => e.Cardnum).HasColumnName("cardnum");

                entity.Property(e => e.Chinaid).HasColumnName("chinaid");

                entity.Property(e => e.Company)
                    .IsRequired()
                    .HasColumnName("company");

                entity.Property(e => e.Edu).HasColumnName("edu");

                entity.Property(e => e.Email).HasColumnName("email");

                entity.Property(e => e.IdimgBack).HasColumnName("idimg-back");

                entity.Property(e => e.IdimgFront).HasColumnName("idimg-front");

                entity.Property(e => e.Locker).HasColumnName("locker");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasColumnName("name");

                entity.Property(e => e.Phone).HasColumnName("phone");

                entity.Property(e => e.Sex).HasColumnName("sex");
            });
        }
    }
}
